#ifndef FTPSOCKET_H_INCLUDED
#define FTPSOCKET_H_INCLUDED

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <stdbool.h>
#include <termios.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <signal.h>
#include <pthread.h>
#include <sys/wait.h>

#define SOCKET int
#define TAILLE_BUFF 512
#define FALSE 0
#define TRUE 1

#define NB_COMMAND_WITH_PASV 4
#define LENGTH_CMD 256

typedef struct s_thread_arg{
    void* socket;
    char* ip;
    bool ssl;
    pthread_mutex_t mutex;
} argThread;

int recoieDonneesNonSsl(int fd, SOCKET* s);
int envoieDonneesNonSsl(SOCKET* s, FILE* fileInput);
SOCKET creeConnectSocketClient(const char *nom_serveur, const char* port);
int getPasvPort(void* s, bool ssl);
void SetStdinEcho(bool enable);
bool isPasvCommand(char* command);

char* recoieMessage(int fd, void* s, bool ssl);
int envoieMessage(void* s, bool ssl, char * format, ...);

void waitCmd(void* s, char *ip, bool ssl);
bool chercheCode(char* message, char* code);

void startNoop(argThread* arg);
void promptUtilisateur(argThread* arg);

bool finMessage(char* buff, char* lastBuff);
void gestionnaireCode(char* message);

#endif // FTPSOCKET_H_INCLUDED
